package com.htfyun.eink.pw.draw.pen;

import android.graphics.Color;
import android.graphics.Paint;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.htfyun.eink.pw.configs.ConfigPen;
import com.htfyun.eink.pw.draw.IPWDrawPath;
import com.htfyun.eink.pw.draw.IPWDrawProperty;
import com.htfyun.eink.pw.draw.cache.IPathCache;
import com.htfyun.eink.pw.draw.pointer.PWPointer;

public class PenRandomEraserPath extends PenRandomEraser {

    public static final String PEN_ID = PenRandomEraserPath.class.getSimpleName();

    @NonNull
    @Override
    public String getPenId() {
        return PEN_ID;
    }

    @Nullable
    @Override
    public IPathCache getPathCache() {
        return null;
    }

    @Override
    public void configPaint(@NonNull Paint paintRandom, @NonNull PWPointer pointer) {
        paintRandom.setStrokeWidth(ConfigPen.ERASER_PATH_STROKE_WIDTH);
        paintRandom.setColor(Color.TRANSPARENT);//不用显示该 擦除 轨迹.
    }

    @NonNull
    @Override
    public PenDrawPointerResultEnums drawPointer(@NonNull IPWDrawPath draw, @NonNull PWPointer pointer) {
        PenDrawPointerResultEnums resultEnums = super.drawPointer(draw, pointer);

        if (draw instanceof IPWDrawProperty) {
            IPWDrawProperty property = (IPWDrawProperty) draw;
            property.getPathCacheManager().checkForEraserPath(getDirty());
        }

        return resultEnums;

    }

}
